<template>
<div>
    <h1>路由嵌套 nested router</h1>
    <router-link to="./yjf">闫俊风</router-link>
     <router-link to="./ys">闫三</router-link>
     <router-view/>
     <hr>
     <button @click="getSong">点击跳转</button>
     <p>歌词翻译者：{{nickname}}</p>
</div>
</template>

<script>
// 注意引入 导入axios工具
import axios from 'axios'
// 导入接口
import {cloudmusic} from '../sever'
export default {
    data(){
        return{
            nickname:''
        }
    },
    methods:{
        getSong(){
            // 保留this指向
            let _this=this    
            // axios.get('https://api.imjad.cn/cloudmusic/?type=lyric&id=28012031')
            // axios.get('https://api.imjad.cn/cloudmusic/',{
                 axios.get(cloudmusic,{
            params:{
                type:'lyric',
                id:'28012031'
            }
            })
            // then是正确的回调
           .then(function (response) {
                console.log(response);
                _this.nickname=response.data.transUser.nickname
            })
            //  catch是错误的回调
            .catch(function (error) {
                console.log(error);
            })
        }
    }
}
</script>

<style scoped>
    
</style>